/*
   FieldVis - A Tool for Visualizing Astrophysical Magnetohydrodynamic Flow
   
   Copyright (C) 2006 - 2008     FieldVis Development Team
  
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
  
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
  
   You should have received a copy of the GNU General Public License along
   with this program; if not, write to the Free Software Foundation, Inc.,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

   File     : ColorMap.h
   Author   : Blayne Field
   
   Purpose  : Definition header file for the ColorMap class.  This class is
              for mapping colors based on some set of values.
*/

#ifndef COLOR_MAP_H
#define COLOR_MAP_H

#include <GL/gl.h>
#include <iostream>
#include <sstream>

#include "Vector3D.h"
#include "Field.h"
#include "TextWriter.h"


class ColorMap
{
public:

   ColorMap(const std::string &fileName);
   ~ColorMap();

   void AssociateField(const std::string &fileName,
                       const int x, const int y, const int z,
                       const float min, const float max);

   Vector3D GetRGBValue(Point &p) const;

   void DrawColorMap(int xStart, int yStart, int width, int height, TextWriter *writer);

private:

   bool UsingField() const    { return( colorField != NULL ); }

   void LoadFile(const std::string &fileName);

   ScalarField *colorField;
   float minValue, maxValue;
   std::vector<Vector3D> colors;
};

#endif
